home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998…tember: Reference Library / Dev.CD Sep 98 RL2.toast / What's New / Software Development Kits / MacOS USB DDK / Examples / PrinterClassDriver / DRVRGlue.a < prev    next >
Encoding:
Text File  |  1998-07-20  |  2.5 KB  |  95 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        DRVRGlue.a
  3. ;
  4. ;    Contains:    DRVR interface
  5. ;
  6. ;    Copyright:     1998 by Apple Computer, Inc., all rights reserved.
  7. ;
  8.  
  9.         
  10.     BLANKS    ON
  11.     STRING    ASIS
  12.         
  13.     INCLUDE        'LowMem.a'
  14.     INCLUDE        'Devices.a'
  15. ;
  16. ;    for an explanation of VMimmune and gestalt see AsyncDriverSample 1.0b4
  17. ;
  18. dVMImmuneMask                EQU    $0001
  19. dDriverGestaltEnableMask    EQU    $0004    ; See DriverGestalt.h
  20.  
  21. drvrFlags        EQU    dReadEnableMask +  dWritEnableMask + dCtlEnableMask +  dStatEnableMask
  22. drvrSystemFlags    EQU dNeedLockMask +  dVMImmuneMask 
  23. ;<oja> +  dDriverGestaltEnableMask
  24.  
  25. DRVREntry        MAIN    EXPORT
  26.  
  27.                 IMPORT    DRVROpen, DRVRPrime, DRVRControl, DRVRStatus, DRVRClose
  28.  
  29. Header
  30.         dc.w    drvrFlags + drvrSystemFlags
  31.         DC.W    0        ; no run time
  32.         DC.W    0        ; no events
  33.         DC.W    0        ; no menu
  34.  
  35. ; Entry point offset table to the procs: Open, Prime, Control, Status, Close
  36.         DC.W    MyOpen        - DRVREntry  ; open routine
  37.         DC.W    MyPrime        - DRVREntry  ; prime
  38.         DC.W    MyControl    - DRVREntry  ; control
  39.         DC.W    MyStatus    - DRVREntry  ; status
  40.         DC.W    MyClose        - DRVREntry  ; close
  41.  
  42. ; Title
  43. ;        include three pad bytes so we can re-number the driver
  44.         DC.B    14                    ;Length byte
  45.         DC.B    '.USB--Print---'    ;Pad to odd # of chars, so 1st routine
  46.                                     ;  will be word-aligned.
  47.  
  48. ; Push the address of the routine we wish to call and jump to the glue
  49. ; which sets up the parameters and calls the actual driver implementation
  50. MyOpen        PEA        DRVROpen
  51.             bra.s    MyGlue
  52. MyPrime        PEA        DRVRPrime
  53.             bra.s    MyGlue
  54. MyControl    PEA        DRVRControl
  55.             bra.s    MyGlue
  56. MyStatus    PEA        DRVRStatus
  57.             bra.s    MyGlue
  58. MyClose        PEA        DRVRClose
  59.  
  60. MyGlue
  61.             MOVEM.L    A0/A1,-(A7)                ; save params to the routine
  62.             CLR.W    -(A7)                    ; make room for result
  63.             MOVE.L    A0,-(A7)                ; pass the parameter block
  64.             MOVE.L    A1,-(A7)                ; pass the device control entry
  65.             MOVEA.L    $0012(A7),A0            ; address of routine to jump to
  66.             JSR        (A0)                    ; do it
  67.             MOVE.W    (A7)+,D0                ; get result
  68.             MOVEM.L    (A7)+,A0/A1                ; restore device parameters
  69.             ADDQ.W    #4,A7                    ; pop routine address to clean up
  70. ;            tst.w    IOParam.ioResult(a0)
  71. ;            beq.s    IOComplete
  72.             BTST    #10,IOParam.ioTrap(A0)    ; test for an async call
  73.             BNE.S    Done                    ; if not async, we're done
  74. IOComplete
  75.             SUBQ.W    #4,A7                    ; else get the JIODone vector
  76.             _LMGetJIODone                    ; so we can jump to it.
  77. Done
  78.             RTS        
  79. ;
  80. ;
  81. ;
  82. DRVRDONE    PROC    EXPORT
  83.             
  84.             MOVE.L    4(sp),a0                ; pass the parameter block
  85.             MOVE.L    8(sp),a1                ; pass the device control entry
  86.             MOVE.W    12(sp),d0
  87.             SUBQ.W    #4,A7                    ; get the JIODone vector
  88.             _LMGetJIODone                    ; jump to it.
  89.             
  90.             RTS
  91.  
  92.             ENDPROC
  93.     END
  94.     
  95.